/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


//khai bao doi tuong truyen thong giua client va server cho Ajax su dung
    var request;
//Phuong thuc nay dung de gui request va nhan respone tu server
    function sendAccount() {
        var userName = document.getElementById("txtUname");
        var passWord = document.getElementById("txtPass");
        //kiem tra xem user co duoc nguoi dung nhap vao ko?
        if (userName.value == "") {
            window.alert("ban da quen nhap userName !");
            userName.focus();
            return false;
        }
        //kiem tra xem passwork co duoc nguoi dung nhap vao ko?
        if (passWord.value == "") {
            window.alert("ban da quen nhap passWord !");
            passWord.focus();
            return false;
        }
        //gui request den lop XuLiDangNhap cung voi userName&password
        var url = "XuLiDangNhap?userName=" + escape(userName.value)
                + "&&passWord=" + escape(passWord.value);
        try
        {
        // Firefox, Opera 8.0+, Safari
        request=new XMLHttpRequest();
        }
        catch (e)
        {
        // Internet Explorer
        try
        {
            request=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
        try
        {
            request=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
        }
        }

        //if (window.XMLHttpRequest) {
        //    alert("firefox");
            //request = new XMLHttpRequest();
        ///} else {
        //    request = new ActiveXObject("Microsoft.XMLHTTP");
        //}
        request.open("Get", url, true);
        request.onreadystatechange = callback;
        request.send(null);
    }
    function callback() {

        if (request.readyState == 4) {
            if (request.status == 200) {
                var hienThi = document.getElementById("hienthi");
                hienThi.innerHTML = request.responseText;
                
            

            }

        }
    }